home *** CD-ROM | disk | FTP | other *** search
- /* graphics:
- math routines
- by Cary Clark, Georgiann Delaney, Michael Fairman, Dave Good, Robert Johnson, Keith McGreggor, Oliver Steele, David Van Brink, Chris Yerga
- Copyright 1987 - 1991 Apple Computer, Inc. All rights reserved. */
-
- #ifndef mathRoutinesIncludes
- #define mathRoutinesIncludes
-
- #ifndef mathTypesIncludes
- #include "math types.h"
- #endif
-
- #ifdef appleInternal
- #define GXInlineCode(x)
- #endif
- #ifndef GXInlineCode
- #define GXInlineCode(x) = {0x303C, x, 0xA832}
- #endif
-
- #ifdef __cplusplus
- extern "C" {
- #endif
-
- gxMapping *CopyToMapping(gxMapping *target, const gxMapping *source) GXInlineCode(0x2013);
- gxMapping *InvertMapping(gxMapping *target, const gxMapping *source) GXInlineCode(0x2014);
- gxMapping *MapMapping(gxMapping *target, const gxMapping *source) GXInlineCode(0x2015);
- gxMapping *MoveMapping(gxMapping *target, fixed hOffset, fixed vOffset) GXInlineCode(0x2016);
- gxMapping *MoveMappingTo(gxMapping *target, fixed hPosition, fixed vPosition) GXInlineCode(0x2017);
- gxMapping *NormalizeMapping(gxMapping *target) GXInlineCode(0x2018);
- gxMapping *RotateMapping(gxMapping *target, fixed angle, fixed xCenter, fixed yCenter) GXInlineCode(0x2019);
- gxMapping *ScaleMapping(gxMapping *target, fixed hFactor, fixed vFactor, fixed xCenter, fixed yCenter) GXInlineCode(0x201A);
- gxMapping *ResetMapping(gxMapping *target) GXInlineCode(0x201B);
- gxMapping *SkewMapping(gxMapping *target, fixed skewX, fixed skewY, fixed xCenter, fixed yCenter) GXInlineCode(0x201C);
-
- void MapPoints(const gxMapping *source, long count, gxPoint vector[]) GXInlineCode(0x201D);
-
- short FirstBit(unsigned long) GXInlineCode(0x201E);
- short WideScale(const gxWide *source) GXInlineCode(0x201F);
-
- short LinearRoot(fixed first, fixed last, fract t[]) GXInlineCode(0x2020);
- short QuadraticRoot(fixed first, fixed control, fixed last, fract t[]) GXInlineCode(0x2021);
-
- gxPoint *PolarToPoint(const gxPolar *, gxPoint *) GXInlineCode(0x2022);
- gxPolar *PointToPolar(const gxPoint *, gxPolar *) GXInlineCode(0x2023);
-
- fract FractCubeRoot(fract source) GXInlineCode(0x2024);
- fract FractDivide(fract dividend, fract divisor) GXInlineCode(0x2025);
- fract FractMultiply(fract multiplicand, fract multiplier) GXInlineCode(0x2026);
- fract FractSineCosine(fixed degrees, fract *cosine) GXInlineCode(0x2027);
- fract FractSquareRoot(fract source) GXInlineCode(0x2028);
-
- fixed FixedDivide(fixed dividend, fixed divisor) GXInlineCode(0x2029);
- fixed FixedMultiply(fixed multiplicand, fixed multiplier) GXInlineCode(0x202A);
-
- /* This next call is (source * multiplier / divisor) -- it avoids underflow, overflow by using wides */
- long MultiplyDivide(long source, long multiplier, long divisor) GXInlineCode(0x202B);
-
- unsigned long Magnitude(long deltaX, long deltaY) GXInlineCode(0x202C);
- long VectorMultiplyDivide(long count, const long *vector1, long step1, const long *vector2, long step2, long divisor) GXInlineCode(0x202D);
-
- gxWide *WideAdd(gxWide *target, const gxWide *source) GXInlineCode(0x202E);
- short WideCompare(const gxWide *target, const gxWide *source) GXInlineCode(0x202F);
- gxWide *WideNegate(gxWide *target) GXInlineCode(0x2030);
- gxWide *WideShift(gxWide *target, long shift) GXInlineCode(0x2031);
- unsigned long WideSquareRoot(const gxWide *source) GXInlineCode(0x2032);
- gxWide *WideSubtract(gxWide *target, const gxWide *source) GXInlineCode(0x2033);
-
- gxWide *WideMultiply(long multiplicand, long multiplier, gxWide *target) GXInlineCode(0x2034);
- long WideDivide(const gxWide *dividend, long divisor, long *remainder) GXInlineCode(0x2035); /* returns the quotient */
- gxWide *VectorMultiply(long count, const long *vector1, long step1, const long *vector2, long step2, gxWide *dot) GXInlineCode(0x2036);
- gxWide *WideWideDivide(gxWide *dividend, long divisor, long *remainder) GXInlineCode(0x203B); /* quotient replaces dividend */
-
- unsigned long RandomBits(long count, long focus) GXInlineCode(0x2037);
- void SetRandomSeed(const gxWide *seed) GXInlineCode(0x2038);
- gxWide *GetRandomSeed(gxWide *seed) GXInlineCode(0x2039);
-
- #ifdef __cplusplus
- }
- #endif
-
- #undef GXInlineCode
-
- #define FixedRound(a) ((short)((fixed)(a) + fixed1/2 >> 16))
- #define FixedSquareRoot(a) ((fixed)FractSquareRoot(a) + 64 >> 7)
- #define FixedTruncate(a) ((short)((fixed)(a) >> 16))
-
- #define FixedToFract(a) ((fract)(a) << 14)
- #define FractToFixed(a) ((fixed)(a) + 8192L >> 14)
-
- #define FixedToInt(a) ((short)((fixed)(a) + fixed1/2 >> 16))
- #define IntToFixed(a) ((fixed)(a) << 16)
-
- #define FixedToFloat(a) ((float)(a) / fixed1)
- #define FloatToFixed(a) ((fixed)((float)(a) * fixed1))
-
- #define FractToFloat(a) ((float)(a) / fract1)
- #define FloatToFract(a) ((fract)((float)(a) * fract1))
-
- #define ColorToFract(a) (((fract) (a) << 14) + ((fract)(a) + 2 >> 2))
- #define FractToColor(a) ((gxColorValue) ((a) - ((a) >> 16) + 8191 >> 14))
-
- #define ff(a) IntToFixed(a)
- #define fl(a) FloatToFixed(a)
-
- #endif
-